<%--
  Created by IntelliJ IDEA.
  User: QiangweiLuo
  Date: 12/19/2018
  Time: 2:24 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>发布新投票</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />
    <script type="text/javascript">
        var isIE = !!document.all;
        function AddOption()
        {
            var voteoptions = document.getElementById("voteoptions");
            var _p = document.createElement("p");
            var _input = document.createElement("input");
            _input.type = "text";
            _input.className = "input-text";
            _input.setAttribute("name", "options");
            _p.appendChild(_input);
            var _a = document.createElement("a");
            _a.className = "del";
            _a.setAttribute("href", "javascript:;");
            if(isIE) {
                _a.attachEvent("onclick", DelOption);
            } else {
                _a.addEventListener("click", DelOption, false);
            }
            _a.appendChild(document.createTextNode("删除"));
            _p.appendChild(_a);
            voteoptions.appendChild(_p);
        }
        function DelOption(e)
        {
            if(!e) e = window.event;
            var a = e.srcElement || e.target;
            var obj = a.parentNode;
            obj.parentNode.removeChild(obj);
        }
    </script>
</head>
<body>
    <%@include file="top.jsp"%>

    <div id="voteManage" class="box" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc3-0" data-genuitec-path="/VoteSite/WebRoot/add.jsp">
        <h2>添加新投票</h2>
        <div class="content">
            <form method="post" action="${pageContext.request.contextPath}/list/add?method=update">
                <dl>
                    <dt>投票内容：</dt>
                    <dd>
                        <input type="hidden" name="id" value="${user.id}"/>
                        <input type="text" class="input-text" name="title" id="title" value="${title}"/>
                    </dd>
                    <dt>开始时间：</dt>
                    <dd>
                        <input type="datetime-local" class="input-text" name="startDate" id="startDate" value="${startDate}"/>
                    </dd>
                    <dt>结束时间：</dt>
                    <dd>
                        <input type="datetime-local" class="input-text" name="endDate" id="endDate" value="${endDate}"/>
                    </dd>
                    <dt>投票类型：</dt>
                    <dd>
                        <input type="radio" name="voteType" <c:if test='${empty type}'>checked</c:if><c:if test='${type == 1}'>checked</c:if> value="1" />单选
                        <input type="radio" name="voteType" <c:if test='${type == 2}'>checked</c:if> value="2" />多选
                    </dd>
                    <dt>投票选项：</dt>

                    <dd id="voteoptions">
                        <p><input type="text" class="input-text" name="options" id="option1" value="${option }"/></p>
                        <p><input type="text" class="input-text" name="options" id="option2" /></p>
                    </dd>


                    <dt></dt>
                    <dd class="button">
                        <input type="image" src="${pageContext.request.contextPath}/images/button_submit.gif" />
                        <a href="javascript:;" onclick="AddOption()">增加选项</a>
                        <%--<a href="Subject!list.action">取消操作</a>--%>
                    </dd>
                </dl>
            </form>
        </div>
    </div>
    <div class="error" id="error">${error }</div>
    <div id="footer" class="wrap">
        艾特优软件 &copy; 版权所有
    </div>
    <script type="text/javascript" src="${pageContext.request.contextPath}/scripts/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/scripts/add.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/scripts/heartbeat.js"></script>
</body>
</html>
